<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/selectCustomer.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.SessionKeys"%>
<%@ page import="com.scalar.chiptrack.users.Functionality"%>
<%@ page import="com.scalar.chiptrack.users.User"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY); %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<!--Added by rohan on August 4th 2003
    This additions have been made to give the functionality of success.jsp to this page aswell-->
<%

    String action=request.getParameter("action");
    if(action == null )
    {
        action = "";
    }else{
        action = action.trim();
    }
  %>
<!--End of additions by rohan on August 4th 2003-->
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<SCRIPT language="JavaScript">
	    function searchCustomer(theForm)
	    {
	        theForm.action.value = "SearchCustomer";
	        theForm.submit();
	    }
        function submitPage()
        {
            document.selectCustomerForm.action.value="SearchCustomer";
            document.selectCustomerForm.submit();
        }

        // SharatH on July 31, 2003
	function showErrorReportPage()
	{
	    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
	    newWindow.focus();
	}

//Added by rohan on July 30th 2003

//Added by rohan on August 4th 2003

//These javascript functions have been added so that this page can be called instead of success.jsp

        function openCustomer()
        {
	    newWindow = window.open('customers.do?action=PrintCustomer&customerId=<%=(String)request.getAttribute("customerId")%>','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=600,left=100,top=50,resizable=yes');
  	    //newWindow.moveTo(100,50);
  	    newWindow.focus();
        }

        function openSalesOrder()
        {
           // newWindow =
		   window.open('order.do?action=printOrder&revisedDate=false&salesOrderId=<%=(String)request.getAttribute("salesOrderId")%>','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=600,left=100,top=50,resizable=yes');
  	        //newWindow.moveTo(100,50);
  	       // newWindow.focus();
        }


 //End of additions by rohan on July 30th 2003

    function openQuotation()
    {
        newWindow = window.open('quotationView.do?action=printQuotation&quotationId=<%=(String)request.getAttribute("quotationId")%>&quotationNo=<%=request.getParameter("quotationNo")%>','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=600,left=100,top=50,resizable=yes');
  	    newWindow.focus();
    }


 //End of additions by rohan on August 4th 2003

</SCRIPT>


<!-- Top Header Start-->
    <%
        String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    %>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<!-- Modified by Prabhanjan on 12 Feb 2004 -->
<%
    String heading = "";

    if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0")))
    {
         heading = "Sample Order";
    %>
        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sample_order_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/ext_sample_order_menu.jsp" %>
        </logic:notEqual>
    <%
    }
    else
    {
        heading = "Quote";
    %>
        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sales_order_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/ext_sales_order_menu.jsp" %>
        </logic:notEqual>
    <%
    }
%>

<!-- end of the side navigations -->

</TD>

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<html:form name="selectCustomerForm" method="post" action="/selectCustomerForQuote" type="com.scalar.chiptrack.sales.forms.SelectCustomerForm" onsubmit="javascript:searchCustomer(document.selectCustomerForm);">

<center><span class="NArialW">Select the Customer for the <%=heading%> </span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
<!--Added by rohan on August 4th 2003 -->
<!-- Added the tags of success.jsp -->
<div align=right>
<table border="0" width="90%">
 <tr><td>
    <chiptrack:info styleClass="NArialL" />
    <chiptrack:errors styleClass="NArialL" />
    <chiptrack:messages type="info" styleClass="NArialL" />

 </td></tr>
</table>
</div>
<!-- End of additions by rohan on August 4th 2003 -->
<br>
<table border="0" width="90%" align=right>
 <tr><td>
  <table border="0" width="100%" align=right>
  <tr>
      <td width="15%"><font class="NArialL">Customer</font></td>
      <td width="20%"><font class="NArialL">
      	<html:text name="selectCustomerForm" property="customerName" styleClass="txfield" size="23" />
      </td>
      <td width="5%"><font class="NArialL">(or)</font>&nbsp;</td>
      <td width="15%"><font class="NArialL">Select Customer</font></td>
      <td width="20%"><font class="NArialL">
        <html:select name="selectCustomerForm" property="selectedCustomer" styleClass="txfield" >
        <html:options collection="customers" property="value" labelProperty="label"/>
        </html:select>
    </tr>
    <tr><td colspan='5'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
      <td colspan=5 align=center>

    	  <!--a href="javascript:searchCustomer(document.selectCustomerForm)">
    <img border="0" src="< %=chipTracContext%>/jsp/includes/images/search.gif"></a-->
    <chiptrack:restrictedLink functionality='<%=Functionality.SALES_NEW_QUOTATION%>' action='<%=User.USER_ACTION_VIEW%>' styleClass="leftsection" href="javascript:searchCustomer(document.selectCustomerForm);" onmouseover="window.status='Click to search for customers';return true" onmouseout="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" title="Click here to Search for the Customer" ></chiptrack:restrictedLink>

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="javascript:document.selectCustomerForm.reset();" onmouseover="window.status='Click to reset the values';return true" title="Click here to Reset" onmouseout="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
      </td>
    </tr>
    <tr><td colspan=5><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr><tr><td>
    <% if ( user1.isActionAllowed ( Functionality.SALES_NEW_QUOTATION,User.USER_ACTION_VIEW ) ) { %>
     <tr><td class="NArialL" colspan=5>To add a new <%=heading%>, please <!--a href="javascript:searchCustomer(document.selectCustomerForm)">click here</a-->
        <chiptrack:restrictedLink functionality='<%=Functionality.SALES_NEW_QUOTATION%>' action='<%=User.USER_ACTION_VIEW%>' styleClass="leftsection" href="javascript:searchCustomer(document.selectCustomerForm);" onmouseover="window.status='Click to Add New Quotation';return true" onmouseout="window.status='';return true">click here</chiptrack:restrictedLink>
    </td></tr>
    <% } %>

    <logic:equal name="showNewCustomerLink" value="TRUE">
    <!--tr><td class="NArialL" colspan=5>To add a new customer, please < html : link page="/customers.do?action=CreateCustomer">click here< / html : link></td></tr-->
    <tr><td class="NArialL" colspan=5>To add a new customer, please <chiptrack:restrictedLink functionality='<%=Functionality.CUSTOMER_DETAILS%>' action='<%=User.USER_ACTION_VIEW%>' styleClass="leftsection" href='<%=chipTracContext + "/customers.do?action=CreateCustomer"%>' onmouseover="window.status='Click to Add New Customer';return true" onmouseout="window.status='';return true">click here</chiptrack:restrictedLink></td></tr>
    </logic:equal>

  </table>
  </td></tr>
  <tr><td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr><tr><td>
    <% int bgcount = 0;%>
    <logic:equal name="showList" value="TRUE">
      <table border="0" width="100%" bordercolor="#FFFFFF" align=right>

  	   <tr><td class="NArialL"><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
             <tr>
               <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Customer Name</font></td>
               <td width="17%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Action</font></td>
             </tr>

             <!--   Commented by rohan on August 4th 2003
                    This error tag is commented as another error tag has been put in this page in the begining of the page
             <tr><td colspan="2"><chiptrack:errors styleClass="NArialL" />   </td></tr>     -->

  	  <logic:iterate id="Customer" name="customersList">
            <% bgcount = bgcount + 1; %>
  	    <tr>
  	     <td width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
  	    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 	<bean:write name="Customer" property="customerName" /></font></td>
  	     <td width="17%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">

                <chiptrack:linkCustomer page="/newQuotation.do?action=NewQuotation&quotation=0" onmouseover="window.status='Click to Enter New Quote';return true" onmouseout="window.status='';return true" >New <%=heading%></chiptrack:linkCustomer>


  		</font>
  	      </td>
  	     </tr>
  	  </logic:iterate>
    </table>
  </logic:equal>
  </td></tr>
</table>
<input type="hidden" name="action" value="">
<input type="hidden" name="isSample" value="<%=request.getParameter("isSample")%>">
</html:form>


<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->

<%@ include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->

</BODY>
</HTML>
